package net.huashitong.ssydt.pk.entity.vo;

import io.swagger.annotations.ApiModelProperty;
import net.huashitong.ssydt.exam.entity.vo.BaseQuestion;
import net.huashitong.ssydt.pk.entity.SsPkYmdxChallengeRecord;
import net.huashitong.ssydt.pk.entity.SsPkYzddChallengeRecord;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author <a href="mailto:yhy23456@163.com">huiyang.yu</a>
 * @since 2017.12.12
 */
public class ChallengeRecordVO implements Serializable {

    private static final long serialVersionUID = 1588824509045855012L;
    @ApiModelProperty(value = "挑战记录id")
    private Long recordId;//挑战记录id
    @ApiModelProperty(value = "总成绩")
    private BigDecimal totalScore;//总成绩
    @ApiModelProperty(value = "卷面成绩")
    private BigDecimal paperScore;//卷面成绩
    @ApiModelProperty(value = "勋章加成")
    private BigDecimal medalScore;//勋章加成
    @ApiModelProperty(value = "月卡加成")
    private BigDecimal cardScore;//月卡加成
    @ApiModelProperty(value = "排名")
    private String rank;//排名
    @ApiModelProperty(value = "上升名次")
    private String riseRank;//上升名次
    @ApiModelProperty(value = "获得金币数")
    private Long goldNumber;//获得金币数
    @ApiModelProperty(value = "选择题列表")
    private List<BaseQuestion> questions;

    public ChallengeRecordVO(SsPkYmdxChallengeRecord record) {
        this.recordId = record.getId();
        this.totalScore = record.getTotalScore();
        this.paperScore = record.getPaperScore();
        this.medalScore = record.getMedalScore();
        this.cardScore = record.getCardScore();
        this.goldNumber = record.getGoldNumber();
        this.riseRank = "";
        if (record.getRank() > 0) {
            this.rank = String.valueOf(record.getRank());
            if (record.getRiseRank() == 0) {
                this.riseRank = "本轮排名没有变化";
            } else if (record.getRiseRank() > 0) {
                this.riseRank = String.format("本轮排名上升%s名", record.getRiseRank());
            } else {
                this.riseRank = String.format("本轮排名下降%s名", -record.getRiseRank());
            }
        } else {
            this.rank = "本轮成绩未进入排行榜，继续加油哦";
        }
    }

    public ChallengeRecordVO() {
    }

    public ChallengeRecordVO(SsPkYzddChallengeRecord record) {
        this.recordId = record.getId();
        this.totalScore = record.getTotalScore();
        this.paperScore = record.getPaperScore();
        this.medalScore = record.getMedalScore();
        this.cardScore = record.getCardScore();
        this.goldNumber = record.getGoldNumber();
        this.riseRank = "";
        if (record.getRank() > 0) {
            this.rank = String.valueOf(record.getRank());
            if (record.getRiseRank() == 0) {
                this.riseRank = "本轮排名没有变化";
            } else if (record.getRiseRank() > 0) {
                this.riseRank = String.format("本轮排名上升%s名", record.getRiseRank());
            } else {
                this.riseRank = String.format("本轮排名下降%s名", -record.getRiseRank());
            }
        } else {
            this.rank = "本轮成绩未进入排行榜，继续加油哦";
        }
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Long getRecordId() {
        return recordId;
    }

    public void setRecordId(Long recordId) {
        this.recordId = recordId;
    }

    public BigDecimal getTotalScore() {
        return totalScore;
    }

    public void setTotalScore(BigDecimal totalScore) {
        this.totalScore = totalScore;
    }

    public BigDecimal getPaperScore() {
        return paperScore;
    }

    public void setPaperScore(BigDecimal paperScore) {
        this.paperScore = paperScore;
    }

    public BigDecimal getMedalScore() {
        return medalScore;
    }

    public void setMedalScore(BigDecimal medalScore) {
        this.medalScore = medalScore;
    }

    public BigDecimal getCardScore() {
        return cardScore;
    }

    public void setCardScore(BigDecimal cardScore) {
        this.cardScore = cardScore;
    }

    public String getRank() {
        return rank;
    }

    public void setRank(String rank) {
        this.rank = rank;
    }

    public String getRiseRank() {
        return riseRank;
    }

    public void setRiseRank(String riseRank) {
        this.riseRank = riseRank;
    }

    public Long getGoldNumber() {
        return goldNumber;
    }

    public void setGoldNumber(Long goldNumber) {
        this.goldNumber = goldNumber;
    }

    public List<BaseQuestion> getQuestions() {
        return questions;
    }

    public void setQuestions(List<BaseQuestion> questions) {
        this.questions = questions;
    }
}
